/**
 * Author(s): xuming.Wong <xuming.Wong@gmail.com>
 */
#include "SystemUtil.h"

#if PLATFORM == PLATFORM_WINDOWS
#include <windows.h>
#endif

void threadSleep(uint millsecs)
{
#if PLATFORM == PLATFORM_WINDOWS
	::Sleep(millsecs) ;
#elif defined(PLATFORM == PLATFORM_LINUX)
	usleep(millsecs*1000) ;
#endif
}

static bool __mouseShow=true;
void showMouseCursor(bool show)
{
	if(show){
		if(__mouseShow){
			return;
		}
		::ShowCursor(true);
		
	}else{
		if(!__mouseShow){
			return;
		}
		::ShowCursor(false);
	}

	__mouseShow=show;
	
}

std::string getCurrentPath()
{
	char buffer[256];
	::GetCurrentDirectory(256,buffer);
	std::string path(buffer);
	return path;
}

void setCurrentPath(std::string path)
{
	::SetCurrentDirectory(path.c_str());
}

void setImmCompositionWindowPos(int x,int y)
{
	HWND hWnd=::GetActiveWindow();
	HIMC hImc=::ImmGetContext(hWnd);
	COMPOSITIONFORM form;
	::ImmGetCompositionWindow(hImc,&form);

	form.ptCurrentPos.x=x;
	form.ptCurrentPos.y=y;
	::ImmSetCompositionWindow(hImc,&form);

}
